<?php include '../templates/hyacinth/common/header.html';?>
<div class="layui-container fly-marginTop fly-user-main">
	<!-- 公告-->
	<?php if(isset($config['notice']) AND $config['notice']):?>
	<blockquote class="layui-elem-quote layui-text" style="background-color: #ffffff;">
		<i class="layui-icon layui-icon-speaker"></i><?php echo $config['notice'];?>
	</blockquote>
	<?php endif;?>
	
	<div class="layui-card">
        <div class="layui-card-body">
			<fieldset class="layui-elem-field">
				<legend>商品信息</legend>
                <div class="layui-row">
                    <div class="layui-col-xs12 layui-col-md4">
                        <div class="layui-field-box">
                            <p><img src="<?php if(strlen($product['imgurl'])>0):?><?php echo $product['imgurl'];?><?else:?>/templates/hyacinth/images/noimg.jpg<?php endif;?>" alt="" height="300px" width="100%"></p>
						</div>
                    </div>
                    <div class="layui-col-xs12 layui-col-md8">
                        <div class="layui-field-box">
							<form class="layui-form layui-form-pane" method="post">
								<p><?php if(isset($product['auto']) AND ($product['auto']>0) ):?><span class="layui-badge layui-bg-green">自动发货</span><?php else:?><span class="layui-badge layui-bg-black">手工发货</span><?php endif;?>&nbsp;&nbsp;<span class="trade-goodname"><?php echo $product['name'];?></span></p><hr>
								<p class="trade-goodinfo">
									<span style="color:#6c6c6c">价格：</span>
									<span class="trade-price">¥ <?php echo $product['price'];?></span>
									<?php if(isset($product['price_ori']) AND $product['price_ori']>0):?><span class="trade-price-ori">¥ <?php echo $product['price_ori'];?></span><?php endif;?>
								</p> 
								
								<?php if(strlen($pifa)>0):?>
								<p class="trade-youhui">
									<span style="color:#6c6c6c">优惠：</span>								
									<span id = "view-youhui" style="padding-top: -10px;height: 100%;cursor: pointer;margin-left: 5px;">查看批发优惠</span>
								</p>
								<?php endif;?>
								
								<div class="layui-form-item">
									<label class="layui-form-label" style="color: #6c6c6c;">数量：</label>
									<div class="layui-input-inline">
										<input type="number" name="number" id="number" lay-verify="required|numberCheck" maxlength=10 value="1" placeholder="" autocomplete="off" class="layui-input">
									</div>
									<div class="layui-form-mid layui-word-aux layui-hide-xs">件&nbsp;(库存:<?php if($product['stockcontrol']>0):?><?php if($product['qty']>0):?><?php echo $product['qty'];?><?php else:?>缺货中<?php endif;?><?php else:?>不限量<?php endif;?>)</div>
								</div>							
								<?php if($login):?>
								<div class="layui-form-item">
									<label class="layui-form-label">邮箱账户</label>
									<div class="layui-input-inline">
										<input type="text" name="email" id="email" value="<?php echo $uinfo['email'];?>" readonly class="layui-input">
									</div>
								</div>
								<?php else:?>
										<?php if(isset($config['orderinputtype']) AND $config['orderinputtype'] == '2'):?>
										<div class="layui-form-item">
											<label class="layui-form-label">QQ：</label>
											<div class="layui-input-inline">
												<input type="number" name="qq" id="qq" class="layui-input" required lay-verify="required|number">
											</div>
										</div>
										<?php else:?>
										<div class="layui-form-item">
											<label class="layui-form-label">邮箱账户</label>
											<div class="layui-input-inline">
												<input type="text" name="email" id="email" class="layui-input" required lay-verify="required|email">
											</div>
										</div>
										<?php endif;?>
								<?php endif;?>
								
								<?php if(isset($config['querycontactswitch']) AND $config['querycontactswitch']>0):?>
								<div class="layui-form-item">
									<label class="layui-form-label">查询密码</label>
									<div class="layui-input-inline">
										<input type="text" name="chapwd" id="chapwd" class="layui-input" required lay-verify="required" placeholder="将作为自助查询订单重要依据">
									</div>
								</div>
								<?php endif;?>
								
								<?php if(!empty($addons)):?>
								<?php foreach($addons AS $key=>$addon):?>
									<?php if($addon):?>
										<div class="layui-form-item">
											<label class="layui-form-label"><?php echo $addon;?></label>
											<div class="layui-input-inline">
												<input type="text" name="addons[]" id="addons<?php echo $key;?>" class="layui-input" required lay-verify="required" placeholder="">
											</div>
										</div>
									<?php endif;?>
								<?php endforeach;?>
								<?php endif;?>
								
								<div class="layui-form-item">
									<div class="layui-input-block">
										<input type="hidden" name="price" id="price" readonly disabled value ="<?php echo $product['price'];?>">
										<input type="hidden" name="qty" id="qty" readonly disabled value ="<?php if($product['stockcontrol']>0):?><?php if($product['qty']>0):?><?php echo $product['qty'];?><?php else:?>库存不足<?php endif;?><?php else:?>不限量<?php endif;?>">
										<input type="hidden" name="stockcontrol" id="stockcontrol" value="<?php echo $product['stockcontrol'];?>">
										<input type="hidden" name="limitorderqty" id="limitorderqty" value="<?php echo $config['limitorderqty'];?>">
										<input type="hidden" name="pid" id="pid" value="<?php echo $product['id'];?>">
										<button class="layui-btn" id="buy" lay-submit lay-filter="buy" <?php if($product['stockcontrol']>0 AND $product['qty']<1):?>disabled="disabled"<?php endif;?>>立即购买</button>
										<button type="reset" class="layui-btn layui-btn-primary">重置</button>
									</div>
								</div>
							</form>
                        </div>
					</div>
				</div>
			</fieldset>
			<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
				<ul class="layui-tab-title">
					<li class="layui-this">商品描述</li>
				</ul>
				<div class="layui-tab-content" style="">
					<div class="layui-tab-item layui-show">
						<?php if(isset($product['description'])):?><?php echo htmlspecialchars_decode(htmlspecialchars_decode($product['description']));?><?php endif;?>
					</div>	  
				</div>
			</div>
        </div>
     </div>

</div>

<?php if(strlen($pifa)>0):?>
<script>
	function changeTwoDecimal_html(x) {
		var f_x = parseFloat(x);
		if (isNaN(f_x)) {
			alert('function:changeTwoDecimal->parameter error');
			return false;
		}
		var f_x = Math.round(x * 100) / 100;
		var s_x = f_x.toString();
		var pos_decimal = s_x.indexOf('.');
		if (pos_decimal < 0) {
			pos_decimal = s_x.length;
			s_x += '.';
		}
		while (s_x.length <= pos_decimal + 2) {
			s_x += '0';
		}
		return s_x;
	}	
</script>
<script id="youhui_tpl" type="text/html">
{{#  if(d.length === 0){ }}
	<blockquote class="layui-elem-quote">无数据....</blockquote>
{{# }else{ }}
	{{# var price = <?php echo $product['price'];?>  }}
	<div class="layui-card">
		<div class="layui-card-header">折扣信息</div>
		<div class="layui-card-body">
			<div class="layui-form">
			  <table class="layui-table">
				<colgroup>
				  <col width="150">
				  <col width="150">
				  <col width="200">
				  <col width="200">
				</colgroup>
				<thead>
				  <tr>
					<th>数量</th>
					<th>折扣</th>
					<th>原价</th>
					<th>折扣价</th>
				  </tr> 
				</thead>
				<tbody>
				{{# layui.each(d, function(index, item){ }}
					<tr>
						<td>{{ item.qty}}</td>
						<td>{{ item.discount}}</td>
						<td>{{ changeTwoDecimal_html(price*item.qty)}}元</td>
						<td>{{ changeTwoDecimal_html(price*item.qty*item.discount)}}元</td>
					</tr>
				{{#  }); }}
				 </tbody>
				</table>
			</div>
		</div>
	</div>
{{#  } }} 
</script>
<?php endif;?>
<!--引入公共底文件-->
<?php include '../templates/hyacinth/common/footer.html';?>
<!--首页广告-->
<script>
layui.use('product');
var PASSWORD_PRODUCT = 0;
<?php if(strlen($pifa)>0):?>
var PIFA = <?php echo $pifa;?>;
<?php else:?>
var PIFA = "";
<?php endif;?>
</script>